package com.neusoft.yuejian_01.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.neusoft.yuejian_01.R;
import com.neusoft.yuejian_01.base.BaseAdapter;
import com.neusoft.yuejian_01.javabean.CourseBean;
import com.neusoft.yuejian_01.model.ConstPhoto;
import com.neusoft.yuejian_01.viewHolder.CourseViewHolder;

import java.util.List;

import it.sephiroth.android.library.picasso.Picasso;

/**
 * Created by Administrator on 2017/10/7.
 */
public class CourseAdapter extends BaseAdapter {

    public CourseAdapter(Context context,List data) {
        super(context,data);
        this.context=context;
    }

    @Override
    protected RecyclerView.ViewHolder onCreateVH(ViewGroup parent, LayoutInflater layoutInflater, int viewType) {
        View itemView = layoutInflater.inflate(R.layout.item_courselist, parent, false);
        CourseViewHolder viewHolder = new CourseViewHolder(itemView);
        return viewHolder;
    }
    @Override
    protected void onBindVH(RecyclerView.ViewHolder holder, List data, int position) {
        CourseBean courselist = (CourseBean) data.get(position);
        CourseViewHolder viewHolder = (CourseViewHolder) holder;
        String courseInfo = courselist.getCc_info();
        String courseName = courselist.getCc_name();
        int cc_id = courselist.getCc_id();
        int courseLevel = courselist.getCc_level();
        String coursePrice = courselist.getCc_price();
        viewHolder.courseInfoView.setText(courseInfo);
        viewHolder.courselevelView.setText(String.valueOf(courseLevel));
        viewHolder.courseNameView.setText(courseName);
        viewHolder.coursepriceView.setText(String.valueOf(coursePrice));
        String coursePic = ConstPhoto.BASE_URL+ConstPhoto.CourseFile+courselist.getCc_pic();
        Picasso.with(context)
                .load(coursePic)
                .placeholder(R.drawable.pic2)
                .into(viewHolder.courseImage);
    }
}
